<%--
  Created by IntelliJ IDEA.
  User: acer
  Date: 2024-8-15
  Time: 20:31
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>添加空气质量信息</title>
</head>
<body>
<center>
    <form  id="frm">
        监测区域：
        <select class="select"  name="districtId" id="districtId">
            <option value="" selected>请选择</option>
            <option value="1">西城区</option>
            <option value="2">东城区</option>
            <option value="3">海淀区</option>
            <option value="4">朝阳区</option>
            <option value="5">丰台区</option>
        </select>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
        监测日期：
        <input type="date" id="monitorTime" name="monitorTime">
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
        PM10值：<input type="text" id="pm10" name="pm10" ><br>
        PM2.5值：<input type="text" id="pm25" name="pm25"><br>
        监测站：<input type="text" id="monitoringStation" name="monitoringStation"><br>
        <input type="button" value="保存" id="btn">
        <input type="reset" value="重置">
        <button οnclick="javascript:history.back();" value="返回">返回</button>
    </form>
</center>
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
<script>
    $("#btn").click(function (){
        var formArray=$("#frm").serializeArray();
        var formObject = {};
        $.each(formArray,function(i,item){
            formObject[item.name] = item.value;
        });

        $.post({
            url:"/add.do",
            async: true,
            cache: false,
            contentType: "application/json",
            data: JSON.stringify(formObject),
            success:function (result){
                if (result.status === "success") {
                    alert(result.message); // 操作成功提示
                } else {
                    alert(result.message); // 操作失败提示
                }
            },
            error: function(xhr, status, error) {
                alert("请求失败: " + error);
            }
        });
    });

</script>

<script>

</script>
</body>
</html>
